/*
 * @Author: wangyingjie
 * @Date: 2021-08-18 14:56:18
 * @Email: wyj@hyrctec.com
 * @LastEditors: wangyingjie
 * @LastEditTime: 2021-08-25 10:31:02
 * @Company: hyrc
 * @FilePath: \TaskErrorManageApi\database\Dao\ProjectProblem\projectProblem_dao.js
 * @Description:
 */
let { pool } = require("../../DBConfig.js")
let { QueryProject, Querymanageinfo, UPDATEProject, Queryremarkinfo, AddProject, DeleteProject } = require('./projectProblem_sql')
module.exports = {
  //删除问题
  deleted: function (params, callback) {
    let { ProjectId } = params
    let sqlparam = [ProjectId]
    pool.query(DeleteProject, sqlparam, function (error, result) {
      if (error) throw error
      callback(result)
    })
  },
  //新增问题
  add: function (datashuju, callback) {
    let sqlparam = [
      datashuju.Id ? datashuju.Id : "",
      datashuju.ProjectId ? datashuju.ProjectId : "",
      datashuju.Follow ? datashuju.Follow : "",
      datashuju.State ? datashuju.State : "",
      datashuju.Priority ? datashuju.Priority : "",
      datashuju.Subject ? datashuju.Subject : "",
      datashuju.AssigneUserID ? datashuju.AssigneUserID : "",
      datashuju.CreateUserID ? datashuju.CreateUserID : "",
      datashuju.CreateDate ? datashuju.CreateDate : "",
      datashuju.UpdateDate ? datashuju.UpdateDate : "",
      datashuju.BugCounts ? datashuju.BugCounts : "",
      datashuju.BadLevel ? datashuju.BadLevel : "",
      datashuju.BreakDownRate ? datashuju.BreakDownRate : "",
      datashuju.StartTime ? datashuju.StartTime : "",
      datashuju.EndTime ? datashuju.EndTime : "",
      datashuju.OverProssece ? datashuju.OverProssece : "",
      datashuju.IsPublish ? datashuju.IsPublish : "",
    ]
    pool.query(AddProject, sqlparam, function (error, result) {
      if (error) throw error
      callback(result)
    })
  },
  // 项目详情表中查询指定项目问题操作
  projectQuery: function (params, callback) {
    let { ProjectId } = params
    let sqlparam = [ProjectId]
    pool.query(QueryProject, sqlparam, function (error, result) {
      if (error) throw error
      callback(result)
    })
  },
  // 项目问题详情查询
  remarkinfoQuery: function (params, callback) {
    let { ProjectId } = params
    let sqlparam = [ProjectId]
    pool.query(Queryremarkinfo, sqlparam, function (error, result) {
      if (error) throw error
      callback(result)
    })
  },
  //项目表查询
  manageinfoQuery: function (callback) {

    pool.query(Querymanageinfo, function (error, result) {
      if (error) throw error
      callback(result)
    })
  },
  //修改详情数据
  UPDATEProject: function (Param, callback) {
    let sqlparam = [
      Param.State ? Param.State : "",
      Param.Priority ? Param.Priority : "",
      Param.BadLevel ? Param.BadLevel : "",
      Param.BreakDownRate ? Param.BreakDownRate : "",
      Param.BugCounts ? Param.BugCounts : "",
      Param.OverProssece ? Param.OverProssece : "",
      Param.IsPublish ? Param.IsPublish : "",
      Param.Id ? Param.Id : "",
    ]
    pool.query(UPDATEProject, sqlparam, function (error, result) {
      if (error) throw error
      callback(result)
    })
  },

}